package net.sxnic.item.action;

import net.sxnic.ugr.UgrActionSupport;
import net.sxnic.ugr.context.AppContext;
import net.sxnic.ugr.user.User;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class Index extends UgrActionSupport {

	private static final long serialVersionUID = -6630318738622783504L;

	private static Logger logger = LoggerFactory.getLogger(Index.class);

	private String indexPage;

	private User user;

	@RequestMapping(value = "/index.jspa", method = RequestMethod.GET)
	public String execute(ModelMap model) throws Exception {

		user = userManager.getUserByUsername(AppContext.getUserName(request));
		indexPage = (StringUtils.isBlank(AppContext.getCssStyle(request))) ? "vistaBlue"
				: AppContext.getCssStyle(request);

		return "main/" + indexPage + "/index";
	}

	public String getIndexPage() {
		return indexPage;
	}

	public void setIndexPage(String indexPage) {
		this.indexPage = indexPage;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
